<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
</head>
<body>

<script src="js/jquery-3.7.1.min.js"></script>

<h1>实训首页</h1>
<hr>
<form id="loginForm">
    <input type="text" placeholder="请输入用户名" name="username"><br>
    <input type="text" placeholder="请输入密码" name="password"><br>
    <button id="loginBut" type="button">登录</button>
</form>


<script>
    $(function (){
        $('#loginBut').on('click',function (){
            //serialize序列化查询参数
            let data=$('#loginForm').serialize();

            $.get('/login',data,function (resp){
                console.log(resp)
                if (resp.code === 1){
                    location.href='main.html';
                }else {
                    alert(resp.msg)
                }
            });
        })
    })
</script>
</body>
</html>